None

object None : Option<Nothing>

Representation of a non-existent value.

Functions

Link copied to clipboard
inline fun all(predicate: (Nothing) -> Boolean): Boolean

Returns the result of applying the predicate to the value if this is Some or true if this is None.

Link copied to clipboard
inline fun any(predicate: (Nothing) -> Boolean): Boolean

Returns the result of applying the predicate to the value if this is Some or false if this is None.

Link copied to clipboard
open override fun asIterable(): Iterable<Nothing>

Returns an iterable that wraps this Option returning its value if it is defined, or an empty iterable if the option is empty.

Link copied to clipboard
open override fun asSequence(): Sequence<Nothing>

Returns a sequence that wraps this Option returning its value if it is defined, or an empty sequence if the option is empty.

Link copied to clipboard
inline fun filter(predicate: (Nothing) -> Boolean): Option<Nothing>

Returns the same Some if the predicate is satisfied for the value. Otherwise returns a None.

Link copied to clipboard
inline fun <R> filterIsInstance(): Option<R>

Returns the same Some casted to type R if it is R. Otherwise returns a None.

Link copied to clipboard
inline fun filterNot(predicate: (Nothing) -> Boolean): Option<Nothing>

Returns the same Some if the predicate is not satisfied for the value. Otherwise returns a None.

Link copied to clipboard
inline fun <R> flatMap(transform: (Nothing) -> Option<R>): Option<R>

Maps value of a Some to a new Option using transform or returns the same None.

Link copied to clipboard
inline fun <R> fold(default: R, transform: (Nothing) -> R): R

Returns result of applying transform on the value of Some or default if this is None.

inline fun <R> fold(default: () -> R, transform: (Nothing) -> R): R

Returns result of applying transform on the value of Some or default if this is None.

Link copied to clipboard
inline fun forEach(action: (Nothing) -> Unit)

Runs action if this is a Some. Returns Unit without any action if this is None.

Link copied to clipboard
open override fun get(): Nothing

Gets the value of a Some or throws an exception.

Link copied to clipboard
open override fun getOrNull(): Nothing?

Gets the value of a Some or null if this is a None.

Link copied to clipboard
open override fun iterator(): Iterator<Nothing>

Returns a singleton iterator returning the option's value if it is defined, or an empty iterator if the option is empty.

Link copied to clipboard
inline fun <R> map(transform: (Nothing) -> R): Option<R>

Maps value of a Some using transform or returns the same None.

Link copied to clipboard
inline fun none(predicate: (Nothing) -> Boolean): Boolean

Returns false if the predicate is met by the value if this is Some or true otherwise.

Link copied to clipboard
inline fun <R> toLeft(right: () -> R): Either<Nothing, R>

Returns a Right containing the given argument right if this is empty, or a Left containing this option's value if it is defined.

Link copied to clipboard
open override fun toList(): List<Nothing>

Returns a singleton list containing the option's value if it is defined, or an empty list if the option is empty.

Link copied to clipboard
inline fun <L> toRight(left: () -> L): Either<L, Nothing>

Returns a Left containing the given argument left if this is empty, or a Right containing this option's value if it is defined.

Link copied to clipboard
open override fun toString(): String
Link copied to clipboard
infix fun <R> zip(other: Option<R>): Option<Pair<Nothing, R>>

Returns Some containing a Pair of values of this and other if both Options are Some. Otherwise returns None.

inline fun <T1, R> zip(other: Option<T1>, transform: (Nothing, T1) -> R): Option<R>

Returns Some containing the result of applying transform to both values of this and other if both Options are Some. Otherwise returns None.

Properties

Link copied to clipboard
val isDefined: Boolean

Returns true if the option is Some. Otherwise returns false.

Link copied to clipboard
open override val isEmpty: Boolean = true

Returns true if the option is None. Otherwise returns false.

Link copied to clipboard
val isNotEmpty: Boolean

Returns true if the option is Some. Otherwise returns false.